<template>
  <div
    v-loading="loading"
    element-loading-text="正在加载服务监控数据，请稍候！"
    element-loading-spinner="el-icon-loading"
  >
    <el-row>
      <el-col :span="12">
        <div id="cpu" />
      </el-col>
      <el-col :span="12">
        <div id="mem" />
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12" class="card-box">
        <CPU :cpu="server.cpu" />
      </el-col>

      <el-col :span="12" class="card-box">
        <MEM :mem="server.mem" :jvm="server.jvm" />
      </el-col>

      <el-col :span="24" class="card-box">
        <SYS :sys="server.sys" />
      </el-col>

      <el-col :span="24" class="card-box">
        <JVM :jvm="server.jvm" :sys="server.sys" />
      </el-col>

      <el-col :span="24" class="card-box">
        <DISK :disk="server.sysFiles" />
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getServer } from '@/api/system/monitor'

export default {
  name: 'ServerMonitor',
  components: {
    CPU: () => import('@/views/system/monitor/server/components/Cpu.vue'),
    MEM: () => import('@/views/system/monitor/server/components/Mem.vue'),
    SYS: () => import('@/views/system/monitor/server/components/Sys.vue'),
    JVM: () => import('@/views/system/monitor/server/components/Jvm.vue'),
    DISK: () => import('@/views/system/monitor/server/components/Disk.vue')
  },
  data() {
    return {
      server: [],
      loading: true
    }
  },
  created() {
    this.getServer()
  },
  methods: {
    getServer() {
      getServer().then(res => {
        this.server = res.data
        this.loading = false
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
